package com.bruan.create_thread;

import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.FutureTask;

public class ThreadTest3 {
    public static void main(String[] args) throws ExecutionException, InterruptedException {
        //3新建callable对象
        Callable<String> callable = new MyCallable(100);
        //4封装为futuretask
        FutureTask<String> f1 = new FutureTask<String>(callable);
        new Thread(f1);
        //5把未来任务对象交给Thread对象
        new Thread(f1).start();
        //6获取get的返回结果
        String rs = f1.get();
        System.out.println(rs);
    }
}
